package com.apes.fico.masterdata.gl.model;

import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @program: apestech
 * @description: 辅助核算
 * @author: Chengxm
 * @create: 2018-12-21 09:10
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = AccountingChartAuxiliary.CONST_TABLE_NAME,indexes = {
        @Index(columnList = "acc_chart_id,acc_auxiliary_project_id",unique = true),
        @Index(columnList = "acc_chart_id,sequence",unique = true)
})
public class AccountingChartAuxiliary implements ApesBean {
    public final static String CONST_TABLE_NAME="mas_acc_chart_auxiliary";
    @Id
    @Column(name = "id", length = 16)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "科目表辅助核算")
    @Comment("编号")
    private String id;

    @NotNull
    @Comment("序号")
    @Column()
    private int sequence;

    @Comment("辅助项目")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "acc_auxiliary_project_id", referencedColumnName = "id")
    private AccountingAuxiliaryProject accAuxiliaryProject;


    @ManyToOne(optional = false,fetch = FetchType.LAZY)
    @JoinColumn(name="acc_chart_id", referencedColumnName="id", nullable = false)
    @Comment("会计科目主键")
    private AccountingChart accChart;


}
